<table class="layui-table" lay-skin="line"  border="1"  id="ice">
	<colgroup>
		<col width="200px">
		<col width="200px">
	
	</colgroup>
    <thead>
	<tr>
		<th width="1%">
	  	  <input  style="display: inline;width: 15px;height: 15px;" width="20" type="checkbox" id="all" onclick="$('.ctxid').prop('checked' , $(this).prop('checked'));tipNamesNum('#key_'+$('.ctxid').length) ;"/>
	  	</th>
	    <!-- <th style="width:3px;padding:10px 10px 10px 10px;" width="20"></th> -->
	    <th>部门名</th>
	</tr>
    </thead>
    <tbody>
    <#assign inx = 0 >
	<#if organList??>
	    <#list organList as organ>
		<#assign inx = inx + 1 >
		<tr class="ukefu-agentstatus parent${organ.parent!''} organtr">
		    <td width="1%">
			<input type="checkbox" onChange="tipNamesNum('#key_${inx!''}')" data-id="${inx}" name="organs" class="ctxid" value="${organ.id!''}" id="user_${organ.id}" style="display:block;width:15px;height:15px;">
		    </td>
		    <td width="89%">${organ.name!''}</td>
		    <input type="hidden" id="name" name="cond" value="${organ.name!''}"/>
		    <input type="hidden" id="organ" name="field" value="${organ.id!''}"/>
		</tr>
	    </#list>
	</#if>
    </tbody>
</table>
<script>
$(document).ready(function(){
	$('#temp').click(function(){
		var ids = "";
		var inx = 0 ;
		$('.ctxid').each(function(){
			if($(this).prop("checked")){
				if(ids!=""){
					ids += "&" ;
				}
				inx = inx ++ ;
				ids += "ids=" + $(this).val();
			}
		});
		tipNamesNum('#key_'+inx) ;
		$('#temp').attr('href' , '/apps/callout/callagentorgan/saveorgan.html?'+ids);
		
	});
	
});	
	function tipNamesNum(id){
		var value = 0 ;
		
		$('.ctxid').each(function(){
			if($(this).prop("checked")){
				var key = $(this).data("id");
				value = value + parseInt($("#key_"+key).val()) + ${namenum!0};
			}
		});
		if(value > ${activity.namenum!0}){
			layer.tips('分配数已超出抽取数量！', id, {  tips: [1, '#3595CC'],  time: 4000});
		}
	}
	$(document).ready(function(){
		$(".ukefu-key").on("keydown", function (e) {
	        if (e.keyCode == 38) {
	        	var inx = parseInt($(e.target).data("inx"))-1 ;
	        	$("#key_"+inx).focus();
	        }else if (e.keyCode == 40) {
	        	var inx = parseInt($(e.target).data("inx"))+1 ;
	        	$("#key_"+inx).focus();
	        }
	    });
	});


</script>